<template>
    <div id="main">
    </div>
</template>

<script>
    export default {
        name:'main',
        data(){
            return {

            }
        },
        created() {
            this.drawHistogarm();
        },
        methods:{
            drawHistogarm(){
                var that=this;
                this.$http.get('statistics/api/stat/priceBusiness').then(function (resp) {
                    console.log(resp)
                var array = resp.data.data;
                    var arr = [];
                    var arr1 = [];
                    for (let i = 0; i < array.length; i++) {
                        arr[i]=array[i].sname
                        arr1[i]=array[i].money
                    }
                var main = document.getElementById('main');
                var myChart = that.$echarts.init(main);
                var option = {
                    title: {
                        text: '店铺收入统计',
                        subtext: 'second mrcai',
                        left: 'center'
                    },
                        xAxis: {
                            type: 'category',
                            data: arr,
                            axisLabel:{
                                interval: 0,//X轴信息全部展示
                                rotate: 50,//60 标签倾斜的角度
                            }
                        },
                        yAxis: {
                            type: 'value'
                        },
                        series: [
                            {
                                data: arr1,
                                type: 'bar'
                            }
                        ]
                    };

                    option && myChart.setOption(option);


               })

            }
        }
    }
</script>

<style>
    #main {
        width: 600px;
        height: 500px;
        margin-left: 25%;
    }
</style>
